#!/usr/bin/python
# -*- coding: utf-8 -*-
import omen.engine.impl.cron_service_impl as csi
import omen.engine.core.applications as ca
import omen.tools.configuration as cc

## sample appli 1
# cron task: create zip file from folder
#   param: folder
#   param: execution frequence (in min)

# define a cron service
# 


# main load configuration file
# use the factory to create right type object
# run the execute method of the service
class BackupService(csi.CronServiceImpl):
    def __init__(self, service_name, conf):
        super(BackupService, self).__init__(service_name, conf)
    
    def _treatment(self):
        #TODO: implement this method
        pass
        
class BackupApplication(ca.Application):
    def __init__(self, conf):
        application_name = conf[ca.ApplicationParamKeys.appli_name_key]
        super(BackupApplication, self).__init__(application_name)
        
        conf_services = conf['services']
        
        # read configuration file
        for service in conf_services:
            #TODO: call the factory here
            # call create service
            pass
        
        
        # launch process or thread
        # add a decorator for process or thread
        
        
if __name__ == '__main__':
    configuration = cc.JSONConf.load_from_file("/conf/backup.conf")
    application = BackupApplication(configuration)
    
    